<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page language="java" import="com.br.dao.ColigadoDao"%>
<%@ page language="java" import="com.br.model.Coligado"%>
<%@ page language="java" import="com.br.utilitarios.funcoes"%>
<%@ page language="java" import="java.util.List"%>
<%@ page language="java" import="java.util.ArrayList"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="shortcut icon" href="resources/if.ico"> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>GesDoc - Gestao Documental</title>
<style type="text/css"> 
@import url(styles.css)
</style>
<link rel="stylesheet" href="style.css" type="text/css" media="screen, projection" />
<!--[if lte IE 6]><link rel="stylesheet" href="style_ie.css" type="text/css" media="screen, projection" /><![endif]-->      
    <script src="sliding/jquery.js" type="text/javascript"></script>
	<script src="sliding/general.js" type="text/javascript"></script>    

	<link href="windows8/Style/Interacao.css" rel="stylesheet" type="text/css" />
    <link href="windows8/Style/jq-metro.css" rel="stylesheet" type="text/css" />
    <script src="windows8/Style/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="windows8/Script/jquery.metro-btn.js" type="text/javascript"></script>
	<% funcoes function = new funcoes(); %>
    <%=function.getJQueryAdm()%>
</head>
<body>
<%
 //Variaveis
 String           vCodUsuario	   = session.getAttribute("codusuario").toString();

 String vUsuario     = session.getAttribute("user").toString();
 String vSenha       = session.getAttribute("pass").toString();
 String vSitAdm      = session.getAttribute("Administrador").toString();  

 session.setAttribute("user",vUsuario);
 session.setAttribute("pass",vSenha);
 session.setAttribute("Administrador",vSitAdm); 
%>
 <div id="paginatop">
 	<p align="left"><img src="resources/gesdoc.png" ></p>
 </div>
 <div id="paginatop2">
 	<a href="index.jsp"><img src="resources/logoff.png"></a>
 </div>
 
 <div id="menulateral">
  <div id="metrobuttons" class="metro-panel"></div>
  <div id="metrobuttons2" class="metro-panel"></div>
 </div>
<%	 
     if (session.getAttribute("operacao") == "adicionar"){
    	//Variaveis
	 	String  vColigado   = request.getParameter("txtColigada");   	
	 	String  vEmpresa    = request.getParameter("txtEmpresa");
 	 	//Objetos
 	 	Coligado    coligado    = new Coligado();
 	 	ColigadoDao coligadoDao = new ColigadoDao();
 	 	
 	 	//Operacoes
 	 	coligado.setCOD_EMPRESA(vEmpresa);
 	 	coligado.setNOM_COLIGADA(vColigado);
 	 	
 	 	try{
 	 		coligado = coligadoDao.gravar(coligado);
%>  
     		<div id="centrallogin">
	 			<p align="center"><img heigth="110%" width="110%" src="resources/gesdoc02.png" ></p>
	 			<p align="center"><strong>&nbsp;&nbsp; Coligado cadastrado com sucesso !</strong>
 	 			<h2><center><strong><a HREF="control.jsp">Voltar</a></strong></center></h2></p>
 			</div>
<% 	
 		}catch(Exception e){
	 		e.printStackTrace();
%>  
     		<div id="centrallogin">
	 			<p align="center"><img heigth="110%" width="110%" src="resources/gesdoc02.png" ></p>
	 			<p align="center"><strong>&nbsp;&nbsp; Erro ao salvar : Erro ao salvar Coligado </strong>
 	 			<h2><center><strong><a HREF="control.jsp">Voltar</a></strong></center></h2></p>
 			</div>
<%		}
 	}%>
<%	 
     if (session.getAttribute("operacao") == "alterar"){
	 	//Variaveis
	 	String  vColigado    = request.getParameter("txtColigada");   	
	 	String  vEmpresa     = request.getParameter("txtEmpresa");
 	 	String  vCodColigado = request.getParameter("txtCodColigada");
 	 	
	 	//Objetos
 	 	Coligado    coligado    = new Coligado();
 	 	ColigadoDao coligadoDao = new ColigadoDao();
 	 	
 	 	//Operacoes
 	 	coligado.setCOD_EMPRESA(vEmpresa);
 	 	coligado.setNOM_COLIGADA(vColigado);
 	 	coligado.setCOD_COLIGADA(Integer.parseInt(vCodColigado));
 	 	try{
 	 		coligado = coligadoDao.atualizar(coligado);
%>  
     		<div id="centrallogin">
	 			<p align="center"><img heigth="110%" width="110%" src="resources/gesdoc02.png" ></p>
	 			<p align="center"><strong>&nbsp;&nbsp; Coligado alterado com sucesso !</strong>
 	 			<h2><center><strong><a HREF="control.jsp">Voltar</a></strong></center></h2></p>
 			</div>
<% 	
 		}catch(Exception e){
	 		e.printStackTrace();
%>  
     		<div id="centrallogin">
	 			<p align="center"><img heigth="110%" width="110%" src="resources/gesdoc02.png" ></p>
	 			<p align="center"><strong>&nbsp;&nbsp; Erro ao salvar : Erro ao salvar Coligado</strong>
 	 			<h2><center><strong><a HREF="index.jsp">Voltar</a></strong></center></h2></p>
 			</div>
<%		}
}%> 	
</body>
</html>